﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ASP.NET_Routing_Table.BusinessLayer
{
    public class ProductsOperations
    {
        public static List<Product> ProductsTable = new List<Product>();

        static ProductsOperations()
        {
            ProductsTable.Add(new Product() {ID=1,Name="HP Laptop",InStock = true });
            ProductsTable.Add(new Product() { ID = 2, Name = "Lenovo Laptop", InStock = false });
            ProductsTable.Add(new Product() { ID = 3, Name = "Dell Laptop", InStock = true });
        }

        public static Product GetNew()
        {
            return new Product();
        }

        public static void AddProduct(Product item)
        {
            ProductsTable.Add(item);
        }

        public static Product GetProduct(int id)
        {
            var product = ProductsTable.Where(p => p.ID == id).FirstOrDefault();
            return product;
        }

        public static List<Product> GetAll()
        {
            return ProductsTable;
        }
    }
}